package com.gmq.chapter02.t3;

/**
 * Created by gmq on 2017/08/22.
 *
 * @version 1.0
 * @since 2017/08/22 16:22
 */
public class PublicVar {

    public String userName = "A";
    public String password = "AA";

    synchronized public void setValue(String userName, String password) {
        try {
            this.userName = userName;
            Thread.sleep(5000);
            this.password = password;
            System.out.println("setValue method thread name=" + Thread.currentThread().getName() + " userName="
            + userName + " password=" + password);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    synchronized public void getValue() {
        System.out.println("getValue method thread name=" + Thread.currentThread().getName() + " userName=" + this.userName +
        " password=" + this.password);
    }
}
